package org.ghost.wechat.platform.dao;

import org.ghost.wechat.platform.common.http.annotation.HttpClientEx;
import org.ghost.wechat.platform.common.http.annotation.RequestMappingEx;
import org.ghost.wechat.platform.dto.WeChatErrorRspDTO;
import org.ghost.wechat.platform.dto.wechat.user.*;
import org.springframework.http.HttpMethod;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author 01
 * 用户管理相关
 */
@HttpClientEx(hostName = "https://api.weixin.qq.com")
public interface IWeChatUserDAO {
    /**
     * 创建标签,一个公众号，最多可以创建100个标签(标签名（30个字符以内）)
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html
     * -1	系统繁忙
     * 45157	标签名非法，请注意不能和其他标签重名
     * 45158	标签名长度超过30个字节
     * 45056	创建的标签数过多，请注意不能超过100个
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      请求对象{"tag":{ "name" : "广东"}}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/tags/create", method = HttpMethod.POST)
    WeChatUserTagRspDTO createUserTag(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatUserTagReqDTO reqDTO);

    /**
     * 获取公众号已创建的标签
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html
     *
     * @param accessToken 调用接口凭据
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/tags/get", method = HttpMethod.GET)
    WeChatUserTagListRspDTO getUserTag(@RequestParam(value = "access_token") String accessToken);

    /**
     * 编辑标签
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html
     * -1	系统繁忙
     * 45157	标签名非法，请注意不能和其他标签重名
     * 45158	标签名长度超过30个字节
     * 45058	不能修改0/1/2这三个系统默认保留的标签
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      请求对象{"tag":{ "id" : 134,"name" : "广东"}}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/tags/update", method = HttpMethod.POST)
    WeChatErrorRspDTO updateUserTag(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatUserTagReqDTO reqDTO);

    /**
     * 删除标签
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html
     * 请注意，当某个标签下的粉丝超过10w时，后台不可直接删除标签。此时，开发者可以对该标签下的openid列表，先进行取消标签的操作，直到粉丝数不超过10w后，才可直接删除该标签。
     * -1	系统繁忙
     * 45058	不能修改0/1/2这三个系统默认保留的标签
     * 45057	该标签下粉丝数超过10w，不允许直接删除
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      请求对象{"tag":{ "id" : 134}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/tags/delete", method = HttpMethod.POST)
    WeChatErrorRspDTO deleteUserTag(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatUserTagReqDTO reqDTO);

    /**
     * 获取标签下粉丝列表
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html
     * -1	系统繁忙
     * 40003	传入非法的openid
     * 45159	非法的tag_id
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      { "tagid" : 134,"next_openid":""//第一个拉取的OPENID，不填默认从头开始拉取 }
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/user/tag/get", method = HttpMethod.POST)
    WeChatUserTagFansRspDTO getUserTagFans(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatUserTagFansReqDTO reqDTO);

    /**
     * 批量为用户打标签(标签功能目前支持公众号为用户打上最多20个标签)
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html
     * -1	系统繁忙
     * 40032	每次传入的openid列表个数不能超过50个
     * 45159	非法的标签
     * 45059	有粉丝身上的标签数已经超过限制，即超过20个
     * 40003	传入非法的openid
     * 49003	传入的openid不属于此AppID
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      {"openid_list":["ocYxcuAEy30bX0NXmGn4ypqx3tI0","ocYxcuBt0mRugKZ7tGAHPnUaOW7Y"],"tagid":134}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/tags/members/batchtagging", method = HttpMethod.POST)
    WeChatErrorRspDTO batchUserTagging(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatBatchUserTaggingReqDTO reqDTO);

    /**
     * 批量为用户取消标签
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html
     * -1	系统繁忙
     * 40032	每次传入的openid列表个数不能超过50个
     * 45159	非法的标签
     * 40003	传入非法的openid
     * 49003	传入的openid不属于此AppID
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      {"openid_list":["ocYxcuAEy30bX0NXmGn4ypqx3tI0","ocYxcuBt0mRugKZ7tGAHPnUaOW7Y"],"tagid":134}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/tags/members/batchuntagging", method = HttpMethod.POST)
    WeChatErrorRspDTO batchUserUnTagging(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatBatchUserTaggingReqDTO reqDTO);

    /**
     * 获取用户身上的标签列表
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/User_Tag_Management.html
     * -1	系统繁忙
     * 40003	传入非法的openid
     * 49003	传入的openid不属于此AppID
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      {"openid":"ocYxcuBt0mRugKZ7tGAHPnUaOW7Y"}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/tags/getidlist", method = HttpMethod.POST)
    WeChatUserTagIdListRspDTO getUserTagIdList(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatUserTagIdListReqDTO reqDTO);

    /**
     * 修改用户备注名(新的备注名，长度必须小于30字符)
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/Configuring_user_notes.html
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      {"openid":"oDF3iY9ffA-hqb2vVvbr7qxf6A0Q","remark":"pangzi"}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/user/info/updateremark", method = HttpMethod.POST)
    WeChatErrorRspDTO updateUserRemark(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatUserRemarkUpdateReqDTO reqDTO);

    /**
     * 取用户基本信息(UnionID机制)
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/Get_users_basic_information_UnionID.html#UinonId
     *
     * @param accessToken 调用接口凭据
     * @param openId      普通用户的标识，对当前公众号唯一
     * @param lang        返回国家地区语言版本，zh_CN 简体，zh_TW 繁体，en 英语
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/user/info", method = HttpMethod.GET)
    WeChatUserUnionInfoRspDTO getUserInfo(@RequestParam(value = "access_token") String accessToken,
                                          @RequestParam(value = "openid") String openId,
                                          @RequestParam(value = "lang", required = false) String lang);

    /**
     * 批量获取用户基本信息(开发者可通过该接口来批量获取用户基本信息。最多支持一次拉取100条)
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/Get_users_basic_information_UnionID.html#UinonId
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      {"user_list":[{"openid":"otvxTs4dckWG7imySrJd6jSi0CWE","lang":"zh_CN"}]}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/user/info/batchget", method = HttpMethod.POST)
    WeChatBatchGetUserUnionRspDTO updateUserRemark(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatBatchGetUserUnionReqDTO reqDTO);

    /**
     * 批量获取关注者openId(一次拉取调用最多拉取10000个关注者的OpenID)
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/Getting_a_User_List.html
     *
     * @param accessToken 调用接口凭据
     * @param nextOpenId  第一个拉取的OPENID，不填默认从头开始拉取
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/user/info", method = HttpMethod.GET)
    WeChatBatchGetUserOpenIdRspDTO batchGetUserOpenId(@RequestParam(value = "access_token") String accessToken, @RequestParam(value = "next_openid") String nextOpenId);

    /**
     * 获取公众号的黑名单列表(该接口每次调用最多可拉取 10000 个OpenID)
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/Manage_blacklist.html
     * -1	系统繁忙
     * 40003	传入非法的openid
     * 49003	传入的openid不属于此AppID
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      {"begin_openid":"OPENID1"}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/tags/members/getblacklist", method = HttpMethod.POST)
    WeChatBatchGetUserOpenIdRspDTO getBlackList(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatGetBlackListReqDTO reqDTO);

    /**
     * 批量拉黑一批用户(一次最多只能拉黑20个用户)
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/Manage_blacklist.html
     * -1	系统繁忙
     * 40003	传入非法的openid
     * 49003	传入的openid不属于此AppID
     * 40032	一次只能拉黑20个用户
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      {"openid_list":["openid1","openId2"]}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/tags/members/batchblacklist", method = HttpMethod.POST)
    WeChatErrorRspDTO batchBlackList(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatBatchBlackListReqDTO reqDTO);

    /**
     * 取消拉黑用户(一次最多只能拉黑20个用户)
     * https://developers.weixin.qq.com/doc/offiaccount/User_Management/Manage_blacklist.html
     * -1	系统繁忙
     * 40003	传入非法的openid
     * 49003	传入的openid不属于此AppID
     * 40032	一次只能拉黑20个用户
     *
     * @param accessToken 调用接口凭据
     * @param reqDTO      {"openid_list":["openid1","openId2"]}
     * @return
     */
    @RequestMappingEx(name = "cgi-bin/tags/members/batchunblacklist", method = HttpMethod.POST)
    WeChatErrorRspDTO batchUnBlackList(@RequestParam(value = "access_token") String accessToken, @RequestBody WeChatBatchBlackListReqDTO reqDTO);
}
